/*
 * DeletePostAction.java
 *
 * Created on 16 czerwiec 2007, 23:23
 *
 */

package arocms.forum;

import arocms.business.ForumPostDAO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author arek
 */
public class DeletePostAction extends Action{
    
    private Logger log = Logger.getLogger(this.getClass());
    
    /** Creates a new instance of DeletePostAction */
    public DeletePostAction() {
    }

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        try {
            Long id = Long.valueOf(request.getParameter("id"));
            new ForumPostDAO().delete(id);
        } catch (NumberFormatException e) {
            log.error(e.toString());
            return mapping.findForward("failure");
        }
        return mapping.findForward("success");
    }
    
}
